package com.black.opsadmin.controller;

import com.black.opsadmin.service.UserService;
import com.black.opscommon.entity.User;
import com.black.opscommon.utils.R;
import com.black.opsoauth2.annotation.Inner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author qiang.zhang
 * @date 2018-11-23
 */
@RestController
@RequestMapping("api")
public class UserController {

    @Autowired
    private UserService userService;


    /**
     * 获取指定用户全部信息by username
     *
     * @return 用户信息
     */
    @Inner
    @GetMapping("/users/{username}")
    public R findByUsername(@PathVariable String username) {


        User user = userService.findByUsername(username);

        return new R<>(user);
    }

    /**
     * 获取指定用户全部信息by email
     *
     * @return 用户信息
     */
    @Inner
    @GetMapping("/users/{email}")
    public R findByEmail(@PathVariable String email) {


        User user = userService.findByEmail(email);

        return new R<>(user);
    }
}
